[PATCH 2/2] restore visibility hidden
authorAndreas Beckmann <anbe@debian.org>
Mon, 14 Dec 2020 20:05:48 +0000 (21:05 +0100)
committerAndreas Beckmann <anbe@debian.org>
Tue, 5 Jan 2021 01:08:00 +0000 (01:08 +0000)
Gbp-Pq: Name 0002-restore-visibility-hidden.patch

18 files changed:
include/pocl_cache.h
include/pocl_file_util.h
lib/CL/clCreateContext.c
lib/CL/devices/bufalloc.h
lib/CL/devices/common.h
lib/CL/devices/devices.c
lib/CL/devices/devices.h
lib/CL/devices/pocl_local_size.h
lib/CL/devices/prototypes.inc
lib/CL/devices/pthread/pthread.c
lib/CL/pocl_cl.h
lib/CL/pocl_cq_profiling.h
lib/CL/pocl_debug.h
lib/CL/pocl_hash.h
lib/CL/pocl_llvm.h
lib/CL/pocl_runtime_config.h
lib/CL/pocl_timing.h
lib/CL/pocl_util.h

index 377aa21a93e26a1762bf3410c3e91a73817e23e2..92ef284503489a67b097366f1753b31a19621289 100644 (file)
@@ -36,6 +36,10 @@ extern "C" {
 
 #include <CL/cl.h>
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 int pocl_cache_init_topdir ();
 
 int
@@ -120,6 +124,10 @@ void pocl_cache_final_binary_path (char *final_binary_path, cl_program program,
                                    unsigned device_i, cl_kernel kernel,
                                    _cl_command_node *command, int specialize);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 
 #ifdef __cplusplus
 }
index a6d73f0a7595dbd6141dbd56079740f71e6a3613..b6b90f8dac1bd695a63f0aa07aa5a798e4d98662 100644 (file)
 extern "C" {
 #endif
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /* Remove a directory, recursively */
 int pocl_rm_rf(const char* path);
 
@@ -67,6 +71,10 @@ int pocl_mk_tempdir (char *output, const char *prefix);
 int pocl_mk_tempname (char *output, const char *prefix, const char *suffix,
                       int *ret_fd);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 3f2c3b34245c4b23c2543bf799500cfdf9def11d..8dbd6603e05b4046edef2e3c194bd31ec318b6a3 100644 (file)
@@ -117,7 +117,7 @@ int context_set_properties(cl_context                    context,
 }
 
 unsigned cl_context_count = 0;
-pocl_lock_t pocl_context_handling_lock = POCL_LOCK_INITIALIZER;
+pocl_lock_t pocl_context_handling_lock __attribute__((visibility("hidden"))) = POCL_LOCK_INITIALIZER;
 
 CL_API_ENTRY cl_context CL_API_CALL
 POname(clCreateContext)(const cl_context_properties * properties,
index e22f3e4c1bb37c9687d1975bb675f90c35bfb6e2..ae4a6f0b5e891c0b4cb5acf9af5e3ba19e42be83 100644 (file)
@@ -40,6 +40,10 @@ extern "C" {
 
 #include "pocl_cl.h"
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 typedef pocl_lock_t ba_lock_t;
 
 #define BA_LOCK(LOCK) POCL_LOCK(LOCK)
@@ -163,6 +167,10 @@ print_chunk (chunk_info_t *chunk);
 void
 print_chunks (chunk_info_t *first);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index e9a6bca990bed51c794afea4c3f1d204cfc585d8..d6e1bcde73e1d370c72d2eede2f95a5bbded9e77 100644 (file)
 extern "C" {
 #endif
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 int llvm_codegen (char *output, unsigned device_i, cl_kernel kernel,
                   cl_device_id device, _cl_command_node *command,
                   int specialize);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void fill_dev_image_t (dev_image_t *di, struct pocl_argument *parg,
                        cl_device_id device);
 
 void fill_dev_sampler_t (dev_sampler_t *ds, struct pocl_argument *parg);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 void pocl_copy_mem_object (cl_device_id dest_dev, cl_mem dest,
                            size_t dest_offset,
                            cl_device_id source_dev, cl_mem source,
@@ -79,40 +91,76 @@ void pocl_migrate_mem_objects (_cl_command_node *node);
 void pocl_scheduler (_cl_command_node * volatile * ready_list,
                      pthread_mutex_t *lock_ptr);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void pocl_exec_command (_cl_command_node * volatile node);
 
 void pocl_ndrange_node_cleanup(_cl_command_node *node);
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
 void pocl_mem_objs_cleanup (cl_event event);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void pocl_broadcast (cl_event event);
 
 void pocl_init_dlhandle_cache ();
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 char *pocl_check_kernel_disk_cache (_cl_command_node *cmd, int specialized);
 
 size_t pocl_cmd_max_grid_dim_width (_cl_command_run *cmd);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void pocl_check_kernel_dlhandle_cache (_cl_command_node *command,
                                        unsigned initial_refcount,
                                        int specialize);
 
 void pocl_release_dlhandle_cache (_cl_command_node *cmd);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 void pocl_setup_device_for_system_memory(cl_device_id device);
 
 void pocl_reinit_system_memory();
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void pocl_set_buffer_image_limits(cl_device_id device);
 
 void* pocl_aligned_malloc_global_mem(cl_device_id device, size_t align, size_t size);
 
 void pocl_free_global_mem(cl_device_id device, void *ptr, size_t size);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 void pocl_print_system_memory_stats();
 
 void pocl_calculate_kernel_hash (cl_program program, unsigned kernel_i,
                                  unsigned device_i);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void pocl_init_default_device_infos (cl_device_id dev);
 
 #ifdef __cplusplus
index 9bf622f464600b0d4d52c57bb3675aee9441da0b..49d16e6351965ba41ca786396eb70719c2c691fe 100644 (file)
@@ -80,7 +80,9 @@
 /* the enabled devices */
 static struct _cl_device_id* pocl_devices = NULL;
 unsigned int pocl_num_devices = 0;
+#if 0
 unsigned int pocl_num_device_types = 0;
+#endif
 
 /* Init function prototype */
 typedef void (*init_device_ops)(struct pocl_device_ops*);
index 2c8c22229ae9a1c71af7fffebf86f57df0c6f07a..15437a16a7444989b416ec394ad4850b41a1854a 100644 (file)
 #include "../pocl_cl.h"
 #include "config.h"
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -62,6 +66,10 @@ unsigned int pocl_get_device_type_count(cl_device_type device_type);
  */
 unsigned int pocl_get_devices(cl_device_type device_type, struct _cl_device_id **devices, unsigned int num_devices);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 /**
  * \brief Return the count of a specific device in the env var POCL_DEVICES
  * \param dev_type a string describing the device ("basic" for instance)
@@ -71,12 +79,20 @@ unsigned int pocl_get_devices(cl_device_type device_type, struct _cl_device_id *
 int pocl_device_get_env_count(const char *dev_type);
 
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /**
  * \brief Unique global memory id for devices with distinct memory from the system memory
  * \return Unique global mem id, id > 0. Zero is reserved for shared system memory
  */
 int pocl_get_unique_global_mem_id();
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 /* the environment variable that lists the enabled devices */
 #define POCL_DEVICES_ENV "POCL_DEVICES"
 
index 0fb7316713288ca49414b11473163b055be8a2f5..738cca2afc047f3151967d62920b6dd60f6794c6 100644 (file)
@@ -25,6 +25,7 @@
 #define POCL_LOCAL_SIZE_H
 
 #include "pocl_cl.h"
+
 /* The generic local size optimizer used by default, in case there's no target
  * specific one defined in the device driver. */
 void pocl_default_local_size_optimizer (cl_device_id dev, size_t global_x,
@@ -32,6 +33,10 @@ void pocl_default_local_size_optimizer (cl_device_id dev, size_t global_x,
                                         size_t *local_x, size_t *local_y,
                                         size_t *local_z);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /* Can be used for devices which support only small work-groups and prefer
  * them to be maximally utilized to use as many of the SIMD lanes as possible.
  * High compute unit utilization is only a secondary goal which typicaly
@@ -42,4 +47,9 @@ void pocl_wg_utilization_maximizer (cl_device_id dev, size_t global_x,
                                     size_t global_y, size_t global_z,
                                     size_t *local_x, size_t *local_y,
                                     size_t *local_z);
+
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #endif
index 91987eb7efba25a22af105bb4d324a17f099273e..3864a74399b15914db6f26f1a606c91c79203d06 100644 (file)
    THE SOFTWARE.
 */
 
+#ifdef _MSC_VER
+#  define PUSH_VISIBILITY_HIDDEN
+#  define POP_VISIBILITY_HIDDEN
+#else
+#  define PUSH_VISIBILITY_HIDDEN _Pragma ("GCC visibility push(hidden)")
+#  define POP_VISIBILITY_HIDDEN _Pragma ("GCC visibility pop")
+#endif
+
 #define GEN_PROTOTYPES(__DRV__)                                               \
+  PUSH_VISIBILITY_HIDDEN                                                      \
   void pocl_##__DRV__##_submit (_cl_command_node *node, cl_command_queue cq); \
   void pocl_##__DRV__##_join (cl_device_id device, cl_command_queue cq);      \
   void pocl_##__DRV__##_flush (cl_device_id device, cl_command_queue cq);     \
@@ -31,7 +40,9 @@
   void pocl_##__DRV__##_wait_event (cl_device_id device, cl_event event);     \
   void pocl_##__DRV__##_update_event (cl_device_id device, cl_event event);   \
   void pocl_##__DRV__##_free_event_data (cl_event event);                     \
+  POP_VISIBILITY_HIDDEN                                                       \
   void pocl_##__DRV__##_init_device_ops (struct pocl_device_ops *ops);        \
+  PUSH_VISIBILITY_HIDDEN                                                      \
   cl_int pocl_##__DRV__##_uninit (unsigned j, cl_device_id device);           \
   cl_int pocl_##__DRV__##_reinit (unsigned j, cl_device_id device);           \
   cl_int pocl_##__DRV__##_init (unsigned j, cl_device_id device,              \
                                                    const char *kernel_name);  \
   cl_int pocl_##__DRV__##_get_builtin_kernel_metadata (void *data,            \
                const char *kernel_name, pocl_kernel_metadata_t *target);      \
-
+  POP_VISIBILITY_HIDDEN
index d0f6d82fd66637b5939663cd7b05678a448b6bc4..700eeb5ac2e5a5a385b1d90be0255489eb217033 100644 (file)
@@ -131,6 +131,7 @@ static cl_device_partition_property pthread_partition_properties[2]
 
 #define FALLBACK_MAX_THREAD_COUNT 8
 
+static
 char scheduler_initialized = 0;
 
 cl_int
index fa7b1f6dc6c548cec737f86a8d6695c768767903..f9816a697f3307b0bfa3d17c3b0d9293346162e7 100644 (file)
@@ -223,8 +223,8 @@ typedef pthread_mutex_t pocl_lock_t;
 /* Symbol aliases are supported */
 
 #  define POname(name) PO##name
-
-#define POdeclsym(name) __typeof__ (name) PO##name;
+#  define POdeclsym(name)                      \
+  __typeof__(name) PO##name __attribute__((visibility("hidden")));
 #  define POCL_ALIAS_OPENCL_SYMBOL(name)                                \
   __typeof__(name) name __attribute__((alias ("PO" #name), visibility("default")));
 #  define POsymAlways(name) POCL_ALIAS_OPENCL_SYMBOL(name)
index aeeaed56fa498baea48fb0eefab38c7e0f8ae9e4..893098ac9015425120dc83a698c0fade9f800573 100644 (file)
 
 #include "CL/cl.h"
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /* This is set to 1 in case the cq profiling was enabled via POCL_TRACING=cq. */
 extern int pocl_cq_profiling_enabled;
 
 void pocl_cq_profiling_init ();
 void pocl_cq_profiling_register_event (cl_event event);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #endif
index 9b9f9058cca358d13af631c611ae8e257c97cc39..9211b3813105f00a5e6bb30ab8523a2f4ff70a97 100644 (file)
@@ -65,6 +65,10 @@ extern "C" {
 #define POCL_FILTER_TYPE_WARN 2
 #define POCL_FILTER_TYPE_ERR 3
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /* Debugging macros. Also macros for marking unimplemented parts of specs or
    untested parts of the implementation. */
 
@@ -109,9 +113,17 @@ extern "C" {
 
 #ifdef POCL_DEBUG_MESSAGES
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
     extern uint64_t pocl_debug_messages_filter;
     extern int stderr_is_a_tty;
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
     #define POCL_DEBUGGING_ON (pocl_debug_messages_filter)
 
     #if __GNUC__ >= 2
@@ -122,11 +134,24 @@ extern "C" {
 
         #define POCL_DEBUG_HEADER(FILTER, FILTER_TYPE) \
             pocl_debug_print_header (__func__, __LINE__, #FILTER, FILTER_TYPE);
+
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
         extern void pocl_debug_output_lock ();
         extern void pocl_debug_output_unlock ();
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
         extern void pocl_debug_messages_setup (const char *debug);
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
         extern void pocl_debug_print_header (const char * func, unsigned line,
                                              const char* filter, int filter_type);
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
         extern void pocl_debug_measure_start (uint64_t* start);
         extern void pocl_debug_measure_finish (uint64_t* start, uint64_t* finish,
                                                const char* msg,
@@ -320,6 +345,10 @@ extern "C" {
     }                                                                         \
   while (0)
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index a9ab939bf1d2e81847dc75ca29220d5d439ce1ca..d74be2491ae611bcf5f4a1a2cb8a8d0d1b846d2e 100644 (file)
@@ -31,6 +31,10 @@ extern "C" {
 
 #include <stdint.h>
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 typedef struct {
     uint32_t state[5];
     uint32_t count[2];
@@ -43,6 +47,10 @@ void pocl_SHA1_Init(SHA1_CTX* context);
 void pocl_SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len);
 void pocl_SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index bd1d47ff81adbb31345f4a766139a89465870687..d2807ff6b12bb3726bea53ded47198812220b02f 100644 (file)
@@ -31,6 +31,11 @@ extern "C" {
 
 /* Returns the cpu name as reported by LLVM. */
 char *get_llvm_cpu_name ();
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /* Returns if the cpu supports FMA instruction (uses LLVM). */
 int cpu_has_fma();
 
@@ -122,6 +127,10 @@ int pocl_llvm_link_program(cl_program program,
 
 int pocl_invoke_clang(cl_device_id Device, const char** Args);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 
 #ifdef __cplusplus
 }
index eb54dd942cbb2f8e75a78628fbb16c3694254933..8b01fa8a1e60eff9395c521678e097254b185090 100644 (file)
 extern "C" {
 #endif
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 int pocl_is_option_set(const char *key);
+
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 int pocl_get_int_option(const char *key, int default_value);
 int pocl_get_bool_option(const char *key, int default_value);
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 const char* pocl_get_string_option(const char *key, const char *default_value);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index afcffd94855537dd140f8f4d53a1ff4cb49baba5..064d968f2deed02dbbab7c8c5fbdcf69a04eb11f 100644 (file)
 extern "C" {
 #endif
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 extern const unsigned pocl_timer_resolution;
 
 uint64_t pocl_gettimemono_ns();
 
 int pocl_gettimereal(int *year, int *mon, int *day, int *hour, int *min, int *sec, int* nanosec);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index ce104602ad7edff1132e979c922f9c5f91a7b98f..66b6f7d0f123e9d4548eae3195d0a2828dfc5190 100644 (file)
 #error aligned malloc unavailable
 #endif
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -56,6 +60,10 @@ extern "C" {
 uint32_t byteswap_uint32_t (uint32_t word, char should_swap);
 float byteswap_float (float word, char should_swap);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 /* set rounding mode */
 void pocl_restore_rm (unsigned rm);
 /* get current rounding mode */
@@ -70,6 +78,10 @@ void pocl_set_ftz (unsigned ftz);
 unsigned pocl_save_ftz ();
 void pocl_restore_ftz (unsigned ftz);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /* Finds the next highest power of two of the given value. */
 size_t pocl_size_ceil2 (size_t x);
 uint64_t pocl_size_ceil2_64 (uint64_t x);
@@ -83,7 +95,15 @@ uint64_t pocl_size_ceil2_64 (uint64_t x);
  * must be a non-zero power of 2.
  */
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void *pocl_aligned_malloc(size_t alignment, size_t size);
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
 #define pocl_aligned_free(x) POCL_MEM_FREE(x)
 
 /* locks / unlocks two events in order of their event-id.
@@ -127,6 +147,10 @@ check_copy_overlap(const size_t src_offset[3],
                    const size_t region[3],
                    const size_t row_pitch, const size_t slice_pitch);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 /**
  * Push a command into ready list if all previous events are completed or
  * in pending_list if the command still has pending dependencies
@@ -136,6 +160,10 @@ pocl_command_push (_cl_command_node *node,
                    _cl_command_node * volatile * ready_list, 
                    _cl_command_node * volatile * pending_list);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /**
  * Return true if a command is ready to execute (no more event in wait list
  * or false if not
@@ -182,10 +210,22 @@ void pocl_abort_on_pthread_error (int status, unsigned line, const char *func);
 
 void pocl_update_event_queued (cl_event event);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void pocl_update_event_submitted (cl_event event);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 void pocl_update_event_running_unlocked (cl_event event);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 void pocl_update_event_running (cl_event event);
 
 void pocl_update_event_complete_msg (const char *func, unsigned line,
@@ -199,6 +239,10 @@ void pocl_update_event_complete_msg (const char *func, unsigned line,
 
 void pocl_update_event_failed (cl_event event);
 
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 const char*
 pocl_status_to_str (int status);
 
@@ -216,6 +260,10 @@ float half_to_float (uint16_t value);
 }
 #endif
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
 /* Common macro for cleaning up "*GetInfo" API call implementations.
  * All the *GetInfo functions have been specified to look alike, 
  * and have been implemented to use the same variable names, so this